/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssp.event;

import ssp.service.FrontendServer;
import ssp.service.FrontendServerManager;
import ssp.service.ServiceEntry;

/**
 * サービスマップを更新する
 * @author yamazaki
 */
public class ServiceMapUpdateEvent extends Event {
    
    private final double t = 0;
    
    public ServiceMapUpdateEvent(double eventTime) {
        super(eventTime);
    }

    @Override
    public void fire() {
        for(FrontendServer frontendServer : FrontendServerManager.getINSTANCE().getFrontendServerList()) {
            for(ServiceEntry entry : frontendServer.getServiceEntry()) {
                frontendServer.updateServiceMap(entry, getEventTime());
            }
        }
        
        if(t > 0) {
            EventQueue eventQueue = EventQueue.getINSTANCE();
            eventQueue.addEvent(new ServiceMapUpdateEvent(eventQueue.getCurrentTime() + t));
        }
    }
    
}
